﻿@namespace Microsoft.FluentUI.AspNetCore.Components
@inherits FluentComponentBase

<div id="@Id">
    <CascadingValue Value="this" IsFixed="true">
        <CascadingValue TValue=INavMenuItemsOwner Value="@this" IsFixed>
            <CascadingValue Value="@Expanded" Name="NavMenuExpanded">
                <CascadingValue Value="@HasChildIcons" Name="NavMenuItemSiblingHasIcon">
                    <FluentTreeView Class="@ClassValue"
                                    Style="@StyleValue"
                                    CurrentSelected="@_currentlySelectedTreeItem"
                                    CurrentSelectedChanged="@HandleCurrentSelectedChangedAsync">
                        @if (Collapsible)
                        {
                            <FluentTreeItem aria-label="@Title"
                                            aria-expanded="@Expanded.ToAttributeValue()"
                                            Id="@_expandCollapseTreeItemId"
                                            Class="navmenu-expander"
                                            @onclick="@ToggleCollapsedAsync"
                                            @onkeydown="@HandleExpandCollapseKeyDownAsync">
                                @if (ExpanderContent is not null)
                                {
                                    <div>
                                        @ExpanderContent
                                    </div>
                                }
                                else
                                {
                                    <FluentIcon Value="@(new CoreIcons.Regular.Size24.Navigation())" Width="20px" />
                                }
                            </FluentTreeItem>
                        }
                        @ChildContent
                    </FluentTreeView>
                </CascadingValue>
            </CascadingValue>
        </CascadingValue>
    </CascadingValue>
</div>